package update;

import java.util.Arrays;

import protocol.CtfActionException;
import utils.Conversions;

/**
 * Represents the player update.
 */
public class PlayerUpdatePacket {
	int numPlayerUpdates;
	byte[] playerUpdatesInBytes;
	
	public int getNumPlayerUpdates() { return numPlayerUpdates; }
	public byte[] getPlayerUpdatesInBytes() { return playerUpdatesInBytes; }
	
	public PlayerUpdatePacket( byte[] response ) throws CtfActionException {
		byte[] headerInBytes = Arrays.copyOfRange(response, 0, 2);
		byte[] bodyInBytes 	 = Arrays.copyOfRange(response, 2, response.length);
		
		if ( bodyInBytes.length == 0 ) return;
		
		this.numPlayerUpdates = Conversions.bytesToInt(headerInBytes);
		this.playerUpdatesInBytes = bodyInBytes;
	}
}

